/**
 * 
 */
package com.jolestar.yayaweibotong.task;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author jolestar@gmail.com
 *
 */
public abstract class CronJob {

	protected String jobName;
	
	protected final Logger log = Logger.getLogger(this.getClass().getName());
	
	public CronJob(String jobName){
		this.jobName = jobName;
	}
	
	public String getJobName(){
		return this.jobName;
	}
	
	public  void doJob(){
		long start = System.currentTimeMillis();
		try{
			this.doRealJob();
		}catch(Exception e){
			log.log(Level.SEVERE,e.getMessage(),e);
		}finally{
			long end = System.currentTimeMillis();
			log.info("cron job:"+this.jobName+" use time:"+((end-start)/1000)+" second.");
		}
	}
	
	protected abstract void doRealJob();
}
